home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <graphics.h>
- #include <alloc.h>
-
- main()
- {
- int errorcode;
- int graphdriver = DETECT;
- int graphmode;
-
- /* Detect and initialize graphics system */
- initgraph(&graphdriver, &graphmode, "c:\\turboc");
- errorcode = graphresult();
- if (errorcode != grOk)
- {
- printf("Graphics error: %s\n",
- grapherrormsg(errorcode));
- exit(1);
- };
-
- settextjustify(CENTER_TEXT, CENTER_TEXT);
- settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 1);
- outtextxy( getmaxx() / 2, getmaxy() / 2,
- "Illustrating user-defined memory allocation");
-
- outtextxy(getmaxx()/2, getmaxy() - 50,
- "Press any key to exit:");
- getch(); /* wait until a key is pressed */
-
- closegraph(); /* Exit graphics library */
- }
- /*------------------------------------------------------------------*/
- void far * far _graphgetmem(unsigned size)
- {
- printf("\nMemory of size %d requested from _graphmem\n",size);
- printf("Press any key to continue...");
- getch();
- /* Allocate memory from far heap */
- return(farmalloc(size));
- }
- /*------------------------------------------------------------------*/
- void far _graphfreemem(void far *memptr, unsigned size)
- {
- printf("\nFreeing memory of size %d (_graphfreemem)\n", size);
- printf("Press any key to continue..");
- getch();
- /* Release far memory */
- farfree(memptr);
- }